package vip.xiaonuo.common.util;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Pattern;

/**
 * @author 墨塵
 * @since 2023/3/2
 */
public class CommonPhoneUtil {

    /**
     * 判断是否为手机号
     * @param phone
     * @return
     */
    public static boolean verifyPhone(String phone) {
        String regex = "^[1]([3-9])[0-9]{9}$";
        boolean isMatch = false;
        if (StringUtils.isEmpty(phone)) {
            return isMatch;
        } else if (phone.length() != 11) {
            return isMatch;
        } else {
            isMatch = Pattern.matches(regex, phone);
        }
        return isMatch;
    }
}
